# to lessen the number of package management operations,
# as many consecutive ones without flags/options are grouped
sub _make_groupings
{
    # normalise the inputs
    @_ = map +(ref) ? $_ : [ $_ ], @_
	or return;

    my @ret = (shift);

    while (@_)
    {
	if (!ref $ret[-1][-1] and !ref $_[0][-1])
	{
	    push @{ $ret[-1] }, @{ shift @_ };
	    next;
	}

	push @ret, shift;
    }

    @ret;
}

update_packages();

package_install((ref) ? @$_ : $_)
    foreach _make_groupings fetchall_array('packages');

package_remove((ref) ? @$_ : $_)
    foreach _make_groupings fetchall_array('packages_remove');

1;
